#include <AT89X52.h>
void main()
unsigned char KeyScan(void) 
{
int x,y,z,k,b;
P2=0xF0;
b=P2;
if(b==0xF0)
{}
else
{
     if(b==0x70)
     {x=0;}
else if(P2==0xB0)
     {x=1;}
else if(P2==0xD0)
     {x=2;}
else if(P2==0xE0)
     {x=3;}

P2=0x0F;
b=P2;
if(P2==0x0F)
{}
else
{
    if(P2==0x07)
    {y=0;}
else if(P2==0x0B)
    {y=1;}
else if(P2==0x0D)
    {y=2;}
else if(P2==0x0E)
    {y=3;}
}
}
z=x+4*y;
if(z==0)
{k=7;P0=0x07;P1=0x7F;}
if(z==1)
{k=8;P0=0x7F;}
if(z==2)
{k=9;P0=0x5F;}
//if(z==3)
//k="+";
if(z==4)
{k=4;P0=0x66;}
if(z==5)
{k=5;P0=0x6D;}
if(z==6)
{k=6;P0=0x7D;}
//if(z==7)
//k="-";
if(z==8)
{k=1;P0=0x06;}
if(z==9)
{k=2;P0=0x5B;}
if(z==10)
{k=3;P0=0x4F;}
//if(z==11)
//k="*";
if(z==12)
{k=0;P0=0x3F;}
//if(z==13)
//{k=".";P0=0x80;}
//if(z==14)
//k="=";
//if(z==15)
//k="/";
}
